Skip to main content

SD 1.5

LoRA stands for Low-Rank Adaptation, a technique for fine-tuning text-to-image diffusion models like Stable Diffusion 1.5. It involves creating a small "LoRA" model that applies tiny changes to the standard checkpoint model. LoRA models are much smaller than checkpoint models, typically 2-200 MB in size compared to 2-7 GB for checkpoint models. This makes them more manageable and easier to load and generate images.

Tip
  • Use a high guidance_scale value when using LoRAs
  • You can use multiple LoRA models and specify corresponding weights that will determine how much each LoRA model will effect the end result

import requests
import json
url = "https://api.imagepipeline.io/sd/text2image/v1"
headers = {
"API-Key": "Your API Key"
}
data = {
"model_id": "sd1.5",
"prompt": "Close up of beautiful young woman with red hair, standing in a field of wildflowers, wearing a flowing white dress, photorealistic, 8k quality",
"negative_prompt": "error, cropped, worst quality, low quality, duplicate, blurry, (unfinished objects), stock image, artifacts, blurry face, ((deformed eyes)), ((deformed face)), bad proportion, (deformed iris), too many fingers",
"num_inference_steps": 20,
"refiner": false,
"samples": 1,
"guidance_scale": 7.5,
"width": 512,
"height": 512,
"lora_models":["c7e734b3-db74-43c8-a50d-d1cc2fa150fc"],
"lora_weights":["0.9"],
"seed": 12345,
"safety_checker": true
}
response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json())

JSON Parameters

ParameterPermissible valuesNotes
model_idstrmodel_id can be found in models page. Filter by SD-1.5 models
promptstr, 75 tokensCheck our Prompt Guide for tips. Please add embeddings prompts to your prompt
negative_promptstr, 75 tokensCheck our Prompt Guide for tips. Please add embeddings prompts to your prompt
num_inference_stepsint, [1-100]Noise is removed with each step, resulting in a higher-quality image over time. Ideal value 20-30
strengthfloat, [0-1]Optional denoise strength
samplesint, [1-4]Generates a maximum of 4 samples per API call
guidance_scalefloat, [1-20]Higher guidance scale prioritizes text prompt relevance but sacrifices image quality. Ideal value 7.5-12.5
widthintWidth in pixels. Lower than or equal to 512 for best results
heightintHeight in pixels. Lower than or equal to 512 for best results
seedintControlling the seed can help you generate reproducible images
lora_modelsstr, arrayPass the model_id(s) of LoRA models that can be found in models page
lora_weightsstr, arrayStrength of the LoRA effect. Differs model to model
safety_checkerbooleanChecks for NSFW images and filters explicit images

Status

Your response will include a status.

  • If the status = SUCCESS, you will also have download_urls that will have the links to your generated image based on the number of samples you have entered. The maximum number of samples that can be generated is 4.
  • If the status = PENDING, you will receive a id. You can use the status endpoint to fetch your image using the id.
  • If the status = FAILURE, you will receive only an error message.

Use the respective endpoint to fetch the status:

  • https://api.imagepipeline.io/sd/text2image/v1/status/{{id}}

  • https://api.imagepipeline.io/sd/image2image/v1/status/{{id}}

  • https://api.imagepipeline.io/sd/inpainting/v1/status/{{id}}

Pass the API-Key as the authorization in the header.